/* eslint-disable @typescript-eslint/no-explicit-any */
import Macro from "../../Macro";

/**
 * 是否启用某个功能模块 宏配置
 * @param conditionStr 
 * @returns 
 */
export function Conditional(conditionStr: string) {
    return function (targetClassPrototype: any, name: string, decr: PropertyDescriptor) {
        const originalMethod = decr.value;
        decr.value = function (...args: any) {

            const condition = Reflect.get(Macro, conditionStr);
            if (condition) {
                return originalMethod.apply(this, args);
            }
        }
    }
}
